#include <eq/event.h>

#include "window.h"

eqClient::Window::Window(eq::Pipe* parent):
eq::Window(parent),
shadowMap(),
shadowMapProgram(),
illumProgram(),
finalProgram()
{
}

bool eqClient::Window::configInitGL(const eq::uint128_t& initID)
{
    if(!eq::Window::configInitGL(initID))
        return false;
    shadowMap.reset(new GLTexture(this->glewGetContext()));
    shadowMapProgram.reset(new ShaderProgram("shader/map.shv", "shader/map.shf", this->glewGetContext()));
    if(!shadowMapProgram->success())
    {
        std::cerr << shadowMapProgram->log() << std::endl;
        return false;
    }
    illumProgram.reset(new ShaderProgram("shader/illum.shv", "shader/illum.shf", this->glewGetContext()));
    if(!illumProgram->success())
    {
        std::cerr << illumProgram->log() << std::endl;
        return false;
    }
    return true;
}

bool eqClient::Window::configExitGL()
{
    illumProgram.reset();
    shadowMap.reset();
    return eq::Window::configExitGL();
}

bool eqClient::Window::processEvent(const eq::Event& event)
{
    if(event.type != eq::Event::WINDOW_RESIZE)
        return eq::Window::processEvent(event);
    else
        return false;
}
